import request from '../utils/request'
import type { Event } from '../types/event'

export const eventApi = {
  // 创建活动
  createEvent(data: Partial<Event>) {
    return request.post<Event>('/events', data)
  },

  // 更新活动
  updateEvent(id: number, data: Partial<Event>) {
    return request.put<Event>(`/events/${id}`, data)
  },

  // 删除活动
  deleteEvent(id: number) {
    return request.delete(`/events/${id}`)
  },

  // 获取活动详情
  getEvent(id: number) {
    return request.get<Event>(`/events/${id}`)
  },

  // 获取活动列表
  getAllEvents() {
    return request.get<Event[]>('/events')
  },

  // 按类型获取活动
  getEventsByType(type: string) {
    return request.get<Event[]>(`/events/type/${type}`)
  },

  // 获取即将开始的活动
  getUpcomingEvents() {
    return request.get<Event[]>('/events/upcoming')
  },

  // 生成活动二维码
  generateQRCode(id: number) {
    return request.post(`/events/${id}/qr-code`)
  },

  // 获取活动报名统计
  getEventStats(id: number) {
    return request.get<{ registrationCount: number; maxParticipants: number }>(`/events/${id}/stats`)
  }
} 